/**
 * Copyright 2011-2011 - Members of the Chaupal Community
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package net.chaupal.Impl.v1.Proof.ConfirmationProtocol;

import java.util.ArrayList;

public final class AliceSequences {

    private ArrayList<CPSequence> aliceSequences = new ArrayList<CPSequence>();

    public static final CPEvent AM1_IT = new CPEvent(CPMessageType.BUCKET_REQUIRES_CONFIRMATION, CPMessageArrivalTiming.IN_TIME);
    public static final CPEvent AM1_LA = new CPEvent(CPMessageType.BUCKET_REQUIRES_CONFIRMATION, CPMessageArrivalTiming.LATE);
    // public static final CPEvent AM1_NV = new CPEvent(CPMessageType.BUCKET_REQUIRES_CONFIRMATION, CPMessageArrivalTiming.NEVER);

    public static final CPEvent AM2_IT = new CPEvent(CPMessageType.REQUEST_CONFIRMATION, CPMessageArrivalTiming.IN_TIME);
    public static final CPEvent AM2_LA = new CPEvent(CPMessageType.REQUEST_CONFIRMATION, CPMessageArrivalTiming.LATE);
    // public static final CPEvent AM2_NV = new CPEvent(CPMessageType.REQUEST_CONFIRMATION, CPMessageArrivalTiming.NEVER);

    public AliceSequences() {

        // Sequences of 1 item
        ArrayList<CPSequence> oneItem = new ArrayList<CPSequence>();

        oneItem.add(new CPSequence(AM1_IT));
        oneItem.add(new CPSequence(AM1_LA));
        // oneItem.add(new CPSequence(AM1_NV));

        oneItem.add(new CPSequence(AM2_IT));
        oneItem.add(new CPSequence(AM2_LA));
        // oneItem.add(new CPSequence(AM2_NV));

        // Sequences of 2 items
        ArrayList<CPSequence> twoItem = new ArrayList<CPSequence>();

        for (CPSequence itemSeq : oneItem) {

            twoItem.addAll(CombinedSequences.addOneEvent(AM1_IT, itemSeq));
            twoItem.addAll(CombinedSequences.addOneEvent(AM1_LA, itemSeq));
            // twoItem.addAll(CombinedSequences.addOneEvent(AM1_NV, itemSeq));

            twoItem.addAll(CombinedSequences.addOneEvent(AM2_IT, itemSeq));
            twoItem.addAll(CombinedSequences.addOneEvent(AM2_LA, itemSeq));
            // twoItem.addAll(CombinedSequences.addOneEvent(AM2_NV, itemSeq));

        }

        // Sequences of 3 items
        ArrayList<CPSequence> threeItem = new ArrayList<CPSequence>();

        for (CPSequence itemSeq : twoItem) {

            threeItem.addAll(CombinedSequences.addOneEvent(AM1_IT, itemSeq));
            threeItem.addAll(CombinedSequences.addOneEvent(AM1_LA, itemSeq));
            // threeItem.addAll(CombinedSequences.addOneEvent(AM1_NV, itemSeq));

            threeItem.addAll(CombinedSequences.addOneEvent(AM2_IT, itemSeq));
            threeItem.addAll(CombinedSequences.addOneEvent(AM2_LA, itemSeq));
            // threeItem.addAll(CombinedSequences.addOneEvent(AM2_NV, itemSeq));

        }

        // Sequences of 4 items
        ArrayList<CPSequence> fourItem = new ArrayList<CPSequence>();

        for (CPSequence itemSeq : threeItem) {

            fourItem.addAll(CombinedSequences.addOneEvent(AM1_IT, itemSeq));
            fourItem.addAll(CombinedSequences.addOneEvent(AM1_LA, itemSeq));
            // fourItem.addAll(CombinedSequences.addOneEvent(AM1_NV, itemSeq));

            fourItem.addAll(CombinedSequences.addOneEvent(AM2_IT, itemSeq));
            fourItem.addAll(CombinedSequences.addOneEvent(AM2_LA, itemSeq));
            // fourItem.addAll(CombinedSequences.addOneEvent(AM2_NV, itemSeq));

        }

        aliceSequences.addAll(oneItem);
        aliceSequences.addAll(twoItem);
        aliceSequences.addAll(threeItem);
        aliceSequences.addAll(fourItem);

    }

    public ArrayList<CPSequence> getSequences() {
        return new ArrayList<CPSequence>(aliceSequences);
    }

}
